<?php

/**
 * https://github.com/top-think/think-swoole
 */
return [
    'http'       => [
        'enable'     => false,
        'host'       => '0.0.0.0',
        'port'       => 8080,
        'worker_num' => swoole_cpu_num(),
        'options'    => [],
    ],
    'websocket'  => [
        'enable'        => false,
        'handler'       => \think\swoole\websocket\Handler::class,
        'ping_interval' => 25000,
        'ping_timeout'  => 60000,
        'room'          => [
            'type'  => 'table',
            'table' => [
                'room_rows'   => 8192,
                'room_size'   => 2048,
                'client_rows' => 4096,
                'client_size' => 2048,
            ],
            'redis' => [
                'host'          => '127.0.0.1',
                'port'          => 6379,
                'max_active'    => 3,
                'max_wait_time' => 5,
            ],
        ],
        'listen'        => [],
        'subscribe'     => [],
    ],
    'rpc'        => [
        'server' => [
            'enable'     => false,
            'host'       => '0.0.0.0',
            'port'       => 9000,
            'worker_num' => swoole_cpu_num(),
            'services'   => [],
        ],
        'client' => [],
    ],
    //队列
    'queue'      => [
        'enable'  => true,
        //键名是队列名称
        'workers' => [
            //下面参数是不设置时的默认配置
            'default'            => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => 1,
            ],
//            //使用@符号后面可指定队列使用驱动
//            'default@connection' => [
//                //此处可不设置任何参数，使用上面的默认配置
//            ],
            //下面参数是不设置时的默认配置
            'PostJob'            => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => env('queue.post_job_worker_num', 5),
            ],
            'PostAuditJob'   => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => env('queue.post_audit_job_worker_num', 5),
            ],
            //截图通知
            'MpsSnapshotNotifyJob'   => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => env('queue.snapshot_notify_job_worker_num', 5),
            ],
            //系统通知
            'SystemNotifyJob'   => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => env('queue.system_notify_job_worker_num', 5),
            ],
            //IM发消息
            'ImSendMessageJob'   => [
                'delay'      => 0,
                'sleep'      => 3,
                'tries'      => 0,
                'timeout'    => 60,
                'worker_num' => env('queue.im_send_message_job_worker_num', 5),
            ],
        ],
    ],
    'hot_update' => [
        'enable'  => env('APP_DEBUG', false),
        'name'    => ['*.php'],
        'include' => [app_path()],
        'exclude' => [],
    ],
    //连接池
    'pool'       => [
        'db'    => [
            'enable'        => false,
            'max_active'    => 3,
            'max_wait_time' => 5,
        ],
        'cache' => [
            'enable'        => true,
            'max_active'    => 3,
            'max_wait_time' => 5,
        ],
        //自定义连接池
    ],
    'ipc'        => [
        'type'  => 'unix_socket',
        'redis' => [
            'host'          => '127.0.0.1',
            'port'          => 6379,
            'max_active'    => 3,
            'max_wait_time' => 5,
        ],
    ],
    'tables'     => [],
    //每个worker里需要预加载以共用的实例
    'concretes'  => [],
    //重置器
    'resetters'  => [],
    //每次请求前需要清空的实例
    'instances'  => [],
    //每次请求前需要重新执行的服务
    'services'   => [],
    //定时器
    'timer'=> [
        'enable'        => true,
        'handler'       => \app\job\swoole\timer\TimerHandler::class,
        'task' => [
            [
                'cron' => '*/2 * * * *',//分，时，日，月，周
                'handler' => '\app\job\crontab\Test@execute'
            ],
//            [
//                'cron' => '*/30 * * * *',//分，时，日，月，周
//                'handler' => '\app\job\crontab\Test@execute2'
//            ],
//            [
//                'cron' => '3-59/15 6-12 */15 1 2-5',//分，时，日，月，周
//                'handler' => '\app\job\crontab\Test@execute2'
//            ]
        ]
    ],
];
